package edu.nf.meituan.model.user;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.nf.db.util.Column;

import java.time.LocalDateTime;

/***
 * 用户实体类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User {
    /**
     * 用户id
     */
    @Column("u_id")
    private Integer userId;
    /**
     * 用户名
     */
    @Column("u_name")
    private String userName;
    /**
     * 密码
     */
    @Column("pwd")
    private String password;
    /**
     * 昵称
     */
    @Column("nickname")
    private String nickname;
    /**
     * 手机号
     */
    @Column("u_phone")
    private String phoneNumber;
    /**
     * 头像
     */
    @Column("u_avatar")
    private String avatar;
    /**
     * 创建时间
     */
    @Column("u_created_at")

    //实现 JWT 认证 - 解决 LocalDateTime序列化异常问题
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "Asia/Shanghai")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createdAt;

}
